﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cecbData;

namespace cecbClasses.Data_Adapters.Email
{
    public class Func_Email
    {
         
            public Func_Email()
            {
                dataContext = new DSSEntities();
            }
            DSSEntities dataContext;




            public String getTeamRefByProRef(String pro_reference)
            {
                //var Ref = (from c in dataContext.Projects
                //           where c.proj_reference == pro_reference
                //           select c).First();

                //String memRef = Ref.proj_team.ToString();

                //return memRef;
                return "";
            }

            //public List<Members> getTeamMembers(String pro_reference)
            //{
            //    List<Members> teamMembers = new List<Members>();


            //    var quary = from c in dataContext.Projects
            //             join b in dataContext.Team_Members on c.proj_team equals b.team_reference
            //             select new
            //             {
            //                 b.mem_reference
            //             };

            //    return quary.ToList<Members>;
            //}


            public string genarateRandomUsername(int Size)
            {
                Random ran = new Random();
                string input = "abcdefghijklmnopqrstuvwxyz";
                StringBuilder builder = new StringBuilder();
                char ch;
                for (int i = 0; i < Size; i++)
                {
                    ch = input[ran.Next(0, input.Length)];
                    builder.Append(ch);
                }
                return builder.ToString();
            }

            public string genarateRandomPassword(int Size)
            {
                Random ran = new Random();
                string input = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
                StringBuilder builder = new StringBuilder();
                char ch;
                for (int i = 0; i < Size; i++)
                {
                    ch = input[ran.Next(0, input.Length)];
                    builder.Append(ch);
                }
                return builder.ToString();
            }

            public bool ConfirmDuplicatedValuesLeo(String impR, String actR, String proR, String impV, String magV, String memR)
            {
                bool IsInserted = false;
                try
                {
                    LeopoldMatrixValues matrixVal = new LeopoldMatrixValues();

                    matrixVal.impt_reference = impR;
                    matrixVal.actv_reference = actR;
                    matrixVal.proj_reference = proR;

                    matrixVal.mtrx_importance = double.Parse(impV);
                    matrixVal.mtrx_magnitude = double.Parse(magV);
                    matrixVal.mtrx_isRelated = true;

                    dataContext.AddToLeopoldMatrixValues(matrixVal);
                    dataContext.SaveChanges();

                    

                    IsInserted = true;
                }
                catch (Exception)
                {

                    IsInserted = false;

                }


                return IsInserted;
            }
        
    }
}
